package drds.data_propagate.entry;


import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;

import java.util.LinkedList;
import java.util.List;

public final class Properties {

    @Setter
    private String key;
    //@Setter
    //private Object value;
    //
    @Setter
    @Getter
    private List<PropertyEntry> propertyEntryList = new LinkedList<PropertyEntry>();


    public void setKey(@NonNull String key) {
        this.key = key;
        //if (this.value!=null){
        //   throw new UnsupportedOperationException("不能优先设置value");
        //}
    }

    public void setValue(Object value) {
        //this.value = value;
        //
        PropertyEntry propertyEntry = new PropertyEntry();
        propertyEntry.setKey(this.key.trim());//这样可以改变引用指向
        propertyEntry.setValue(value);
        this.propertyEntryList.add(propertyEntry);
    }

    public static class PropertyEntry {
        @Setter
        @Getter
        private String key;
        @Setter
        @Getter
        private Object value;
    }
}
